package com.example.concurrent.chapter19;

/**
 * @author Create By Liuqz
 * @date 2018/11/27 15:13
 */
public class Test {

    public static void main(String[] args) throws InterruptedException {
/*
        //提交一个没有返回值的任务,当调用submit方法之后h会立即返回不再进入阻塞

        //定义不需要返回值的FutureService
        FutureService<Void,Void> service = FutureService.newService();

        //submit方法为立即返回的方法(没有返回值)
        Future<?> future = service.submit(() -> {
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("I am finish done.");
        });

        future.get();*/

        //定义有返回值的FutureService
        /*FutureService<String,Integer> service = FutureService.newService();

        Future<Integer> future = service.submit(input -> {
            try {
                TimeUnit.SECONDS.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return input.length();
        },"Hello");

        System.out.println(future.get());*/

    }
}
